{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "QUANTAXIS>> start QUANTAXIS\n",
      "QUANTAXIS>> Selecting the Best Server IP of TDX\n",
      "QUANTAXIS>> === The BEST SERVER ===\n",
      " stock_ip 115.238.90.165 future_ip 61.152.107.141\n",
      "QUANTAXIS>> Welcome to QUANTAXIS, the Version is remake-version\n",
      "QUANTAXIS>>  \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      "  ``########`````##````````##``````````##`````````####````````##```##########````````#``````##``````###```##`````######`` \n",
      "  `##``````## ```##````````##`````````####````````##`##```````##```````##```````````###``````##````##`````##```##`````##` \n",
      "  ##````````##```##````````##````````##`##````````##``##``````##```````##``````````####```````#```##``````##```##``````## \n",
      "  ##````````##```##````````##```````##```##```````##```##`````##```````##`````````##`##```````##`##```````##````##``````` \n",
      "  ##````````##```##````````##``````##`````##``````##````##````##```````##````````##``###```````###````````##`````##`````` \n",
      "  ##````````##```##````````##``````##``````##`````##`````##```##```````##```````##````##```````###````````##``````###```` \n",
      "  ##````````##```##````````##`````##````````##````##``````##``##```````##``````##``````##`````##`##```````##````````##``` \n",
      "  ##````````##```##````````##````#############````##```````##`##```````##`````###########`````##``##``````##`````````##`` \n",
      "  ###```````##```##````````##```##```````````##```##```````##`##```````##````##`````````##```##```##``````##```##`````##` \n",
      "  `##``````###````##``````###``##`````````````##``##````````####```````##```##``````````##``###````##`````##````##`````## \n",
      "  ``#########``````########```##``````````````###`##``````````##```````##``##````````````##`##``````##````##`````##````## \n",
      "  ````````#####`````````````````````````````````````````````````````````````````````````````````````````````````````####` \n",
      "  ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      "  ``````````````````````````Copyright``yutiansut``2017``````QUANTITATIVE FINANCIAL FRAMEWORK````````````````````````````` \n",
      "  ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " \n"
     ]
    }
   ],
   "source": [
    "import QUANTAXIS as QA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collection(Database(MongoClient(host=['127.0.0.1:27017'], document_class=dict, tz_aware=False, connect=True), 'quantaxis'), 'stock_day')\n"
     ]
    }
   ],
   "source": [
    "data=QA.QA_fetch_stock_day_adv('600177', start='2017-04-01', end='2017-07-01').to_hfq()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "l=data.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date        code  \n",
       "2017-04-05  600177    1.000000\n",
       "2017-04-06  600177    1.000000\n",
       "2017-04-07  600177    1.000000\n",
       "2017-04-10  600177    1.000000\n",
       "2017-04-11  600177    1.000000\n",
       "2017-04-12  600177    1.000000\n",
       "2017-04-13  600177    1.000000\n",
       "2017-04-14  600177    1.000000\n",
       "2017-04-17  600177    1.000000\n",
       "2017-04-18  600177    1.000000\n",
       "2017-04-19  600177    1.000000\n",
       "2017-04-20  600177    1.000000\n",
       "2017-04-21  600177    1.000000\n",
       "2017-04-24  600177    1.000000\n",
       "2017-04-25  600177    1.000000\n",
       "2017-04-26  600177    1.000000\n",
       "2017-04-27  600177    1.000000\n",
       "2017-04-28  600177    1.000000\n",
       "2017-05-02  600177    1.000000\n",
       "2017-05-03  600177    1.000000\n",
       "2017-05-04  600177    1.000000\n",
       "2017-05-05  600177    1.000000\n",
       "2017-05-08  600177    1.000000\n",
       "2017-05-09  600177    1.000000\n",
       "2017-05-10  600177    1.000000\n",
       "2017-05-11  600177    1.000000\n",
       "2017-05-12  600177    1.000000\n",
       "2017-05-15  600177    1.000000\n",
       "2017-05-16  600177    1.000000\n",
       "2017-05-17  600177    1.000000\n",
       "2017-05-18  600177    1.000000\n",
       "2017-05-19  600177    1.000000\n",
       "2017-05-22  600177    1.000000\n",
       "2017-05-23  600177    1.000000\n",
       "2017-05-24  600177    1.000000\n",
       "2017-05-25  600177    1.000000\n",
       "2017-05-26  600177    1.000000\n",
       "2017-05-31  600177    1.000000\n",
       "2017-06-01  600177    1.000000\n",
       "2017-06-02  600177    1.451433\n",
       "2017-06-05  600177    1.451433\n",
       "2017-06-06  600177    1.451433\n",
       "2017-06-07  600177    1.451433\n",
       "2017-06-08  600177    1.451433\n",
       "2017-06-09  600177    1.451433\n",
       "2017-06-12  600177    1.451433\n",
       "2017-06-13  600177    1.451433\n",
       "2017-06-14  600177    1.451433\n",
       "2017-06-15  600177    1.451433\n",
       "2017-06-16  600177    1.451433\n",
       "2017-06-19  600177    1.451433\n",
       "2017-06-20  600177    1.451433\n",
       "2017-06-21  600177    1.451433\n",
       "2017-06-22  600177    1.451433\n",
       "2017-06-23  600177    1.451433\n",
       "2017-06-26  600177    1.451433\n",
       "2017-06-27  600177    1.451433\n",
       "2017-06-28  600177    1.451433\n",
       "2017-06-29  600177    1.451433\n",
       "2017-06-30  600177         NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(l.close/l.preclose.shift(-1)).cumprod()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date        code  \n",
       "2017-04-05  600177          NaN\n",
       "2017-04-06  600177    14.030000\n",
       "2017-04-07  600177    14.100000\n",
       "2017-04-10  600177    14.160000\n",
       "2017-04-11  600177    14.140000\n",
       "2017-04-12  600177    13.930000\n",
       "2017-04-13  600177    13.920000\n",
       "2017-04-14  600177    13.760000\n",
       "2017-04-17  600177    13.790000\n",
       "2017-04-18  600177    13.650000\n",
       "2017-04-19  600177    13.650000\n",
       "2017-04-20  600177    13.700000\n",
       "2017-04-21  600177    13.810000\n",
       "2017-04-24  600177    13.910000\n",
       "2017-04-25  600177    13.760000\n",
       "2017-04-26  600177    13.740000\n",
       "2017-04-27  600177    13.650000\n",
       "2017-04-28  600177    13.680000\n",
       "2017-05-02  600177    13.840000\n",
       "2017-05-03  600177    13.840000\n",
       "2017-05-04  600177    13.850000\n",
       "2017-05-05  600177    13.890000\n",
       "2017-05-08  600177    13.980000\n",
       "2017-05-09  600177    13.950000\n",
       "2017-05-10  600177    13.920000\n",
       "2017-05-11  600177    13.890000\n",
       "2017-05-12  600177    13.910000\n",
       "2017-05-15  600177    13.890000\n",
       "2017-05-16  600177    13.990000\n",
       "2017-05-17  600177    13.960000\n",
       "2017-05-18  600177    13.910000\n",
       "2017-05-19  600177    13.920000\n",
       "2017-05-22  600177    13.770000\n",
       "2017-05-23  600177    13.650000\n",
       "2017-05-24  600177    13.720000\n",
       "2017-05-25  600177    13.860000\n",
       "2017-05-26  600177    14.160000\n",
       "2017-05-31  600177    14.160000\n",
       "2017-06-01  600177    14.120000\n",
       "2017-06-02  600177    14.110000\n",
       "2017-06-05  600177    14.136955\n",
       "2017-06-06  600177    13.991812\n",
       "2017-06-07  600177    14.325641\n",
       "2017-06-08  600177    15.022329\n",
       "2017-06-09  600177    14.746557\n",
       "2017-06-12  600177    15.036843\n",
       "2017-06-13  600177    15.051358\n",
       "2017-06-14  600177    14.746557\n",
       "2017-06-15  600177    14.732043\n",
       "2017-06-16  600177    14.659471\n",
       "2017-06-19  600177    14.717528\n",
       "2017-06-20  600177    14.630442\n",
       "2017-06-21  600177    14.615928\n",
       "2017-06-22  600177    14.717528\n",
       "2017-06-23  600177    14.761071\n",
       "2017-06-26  600177    14.978786\n",
       "2017-06-27  600177    14.877186\n",
       "2017-06-28  600177    14.746557\n",
       "2017-06-29  600177    14.732043\n",
       "2017-06-30  600177    14.688500\n",
       "dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l.close*(l.close/l.preclose.shift(-1)).cumprod().shift(1)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
